package com.jacobson.core.widget.security

import com.jacobson.core.widget.security.authc.AuthenticationToken
import com.jacobson.core.widget.security.authc.Authenticator
import com.jacobson.core.widget.security.exception.AuthenticationException

/**
 * ================================================
 *  安全管理
 *  @author Wucz on 2018/8/6 14:56
 * ================================================
 */
interface SecurityManager : Authenticator {

    /**
     * 获取安全路由
     *
     * @return 路由
     */
    fun getSecurityRouter(): SecurityRouter

    /**
     * 登录
     *
     * @param subject 登录对象
     * @param token   待认证Token
     * @return 认证成功对象
     * @throws AuthenticationException 授权失败抛出异常
     */
    @Throws(AuthenticationException::class)
    fun login(subject: Subject, token: AuthenticationToken): Subject

    /**
     * 退出登录
     *
     * @param subject 待退出登录的对象
     */
    fun logout(subject: Subject)

    /**
     * 创建Subject
     *
     * @param context 上下文
     * @return 新的Subject对象
     */
    fun createSubject(context: SubjectContext?): Subject
}
